package nl.myhealth.app.myhealthapp.Measurement;

import org.json.JSONObject;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Stephan E G Veenstra on 28-9-2014.
 */
public abstract class Measurement {

    private Date timestamp;

    protected Measurement(Date timestamp)
    {
        setTimestamp(timestamp);
    }
    protected Measurement(){}

    public void setTimestamp(Date timestamp)
    {
        this.timestamp = timestamp;
    }

    public void setTimestamp(String timestamp) {
        try {
            setTimestamp(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(timestamp));
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public Date getTimestamp()
    {
        return this.timestamp;
    }

    public String getTimestampString()
    {
        String timestampString = "";

        DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        timestampString = df.format(getTimestamp());

        return timestampString;
    }

    abstract public String toJsonString();
}
